# -*- coding:utf-8 -*-

from agt2.models import *
from django.contrib import admin

admin.site.register(Squad)
admin.site.register(Unit)
admin.site.register(Game)

admin.site.unregister(User)

class UserAdmin(admin.ModelAdmin):

    def save_model(self, request, obj, form, change):
        user = Unit(pk=obj.id)
        user.save()
        return super(UserAdmin, self).save_model(request, obj, form, change)

    def save_form(self, request, form, change):
        obj = form.save(commit=False)
        user = Unit(pk=obj.id)
        user.save()
        return obj

admin.site.register(User, UserAdmin)
